<%@ page pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>View - ${website}</title>
	<%@ include file="/common/meta.jsp"%>
</head>
<body>
	<fieldset>
		<legend>field格式</legend>
		<form action="${ctx}/demo/save" method="post">
			<div><%-- 注意: name的写法, 没有javabean.field的格式, 如何表达多个bean的情况呢? --%>
				<input type="text" name="foo" value="${javaBean.foo}" />
			</div>
			<div>
				<input type="text" name="tee" value="${javaBean.tee}" />
			</div>
			<div>
				<button type="submit">确定</button>
			</div>
		</form>
	</fieldset>
	<fieldset>
		<legend>bean.field格式(暂不行)</legend>
		<form action="${ctx}/demo/save2" method="post">
			<div>
				<input type="text" name="javaBean.foo" value="${javaBean.foo}" />
			</div>
			<div>
				<input type="text" name="javaBean.tee" value="${javaBean.tee}" />
			</div>
			<div>
				<button type="submit">确定</button>
			</div>
		</form>
	</fieldset>
	
	<button type="button" id="post-ajax">提交By ajax</button>
	<button type="button" id="read-json-1">提交json(Object)</button>
	<script type="text/javascript">
		$(function() {
			$('#post-ajax').click(function(e) {
				$.post('${ctx}/demo/ajax', {foo:"foo 1",tee:"ab-1"}, function(callback) {
					console.log(callback);
				});
			});
			$('#read-json-1').click(function(e) {
				$.ajax({
					type : 'POST',
					contentType: 'application/json',
					url : '${ctx}/demo/json',
					data : {foo:"foo 1",tee:"ab-1"},
					dataType : 'json',
					success : function(callback) {
						console.log(callback);
					}
				});
			});
		});
	</script>
</body>
</html>
